/*
 * @Author: wws1993
 * @Date: 2022-04-07 10:31:31
 * @LastEditTime: 2023-02-01 15:29:12
 * @LastEditors: wws1993 15696141050@163.com
 * @Description:
 * @FilePath: \demos\swagger2ts\v2.0\config.js
 * IE6粉丝头子
 * @history: v1.0
 */

/** @type {import('./type.d').TConfig} */
const config = {
  scm_pc: {
    swaggerurl: 'http://123.56.190.103:9907/v2/api-docs',
    commonReqKeys: 'companyLogin,userId,userName'.split(','),
    root: '/apis',
    apiFileName: 'api.js',
    apiTemplateForHeader: `// @ts-nocheck
import { jsonAjax } from '@/apis/request'

/**
 * @typedef RequestExtraCofig
 * @type {import('@/apis/request.type').RequestCofig}
 */
    `,
    apiTemplateForItem: `
/** {{apiDesc}}
 * @param {{{reqDto}}} data 请求入参
 * @param {RequestExtraCofig} extra 额外请求参数
 * @returns {Promise<{{resDto}}>}
 */
export const {{apiName}} = (data = {}, extra = {}) => jsonAjax({url: '{{url}}', data, ...extra});
    `,
    entryImportType: 'js'
  },
  zjs_customer_h5: {
    swaggerurl: 'http://123.56.190.103:9906/v2/api-docs',
    commonReqKeys: 'customerId,companyLogin,pageCount,pageNo'.split(','),
    root: '/apis',
    apiFileName: 'http.api.ts',
    apiTemplateForHeader: `import { serverPost, RequestOption  } from "."`,
    apiTemplateForItem: `\n
/** {{apiDesc}}
 * @param data 请求入参
 * @param loadingText loading文本
 */
export const {{apiName}} = (data: {{reqDto}}, config?: RequestOption, loadingText?: string): Promise<{{resDto}}> => serverPost('{{url}}', {data, ...config}, loadingText);`,
    entryImportType: 'ts'
  },
  scm_applet_driver: {
    swaggerurl: 'http://123.56.190.103:9914/v2/api-docs',
    commonReqKeys: 'customerId,companyLogin,pageCount,pageNo'.split(','),
    root: '/apis',
    apiFileName: 'index.ts',
    apiTemplateForHeader: `
import useResquest, { IRequestOption } from "@/hooks/useResquest";
const { Post } = useResquest();

export default {}
`,
    apiTemplateForItem: `
/** {{apiDesc}}
 * @param data 请求入参
 * @param config 配置
 */
{{apiName}}(data: {{reqDto}}, config?: IRequestOption): Promise<{{resDto}}> {
  return Post('{{url}}', data, config)
},`,
    entryImportType: 'ts'
  },
  scm_applet_admin: {
    swaggerurl: 'http://123.56.190.103:9915/v2/api-docs',
    commonReqKeys: 'customerId,companyLogin,pageCount,pageNo'.split(','),
    root: '/apis',
    apiFileName: 'index.ts',
    apiTemplateForHeader: `
import useResquest, { IRequestOption } from "@/hooks/useResquest";
const { Post } = useResquest();

export default {}
`,
    apiTemplateForItem: `
/** {{apiDesc}}
 * @param data 请求入参
 * @param config 配置
 */
{{apiName}}(data: {{reqDto}}, config?: IRequestOption): Promise<{{resDto}}> {
  return Post('{{url}}', data, config)
},`,
    entryImportType: 'ts'
  }
}

module.exports = config